
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports _2bMatesSite.Common

Namespace _2bMatesSite.BO
	''' <summary>
	''' Base class for blogs (e.g. userblog, and groupblog)
	''' </summary>
	Public MustInherit Class BaseBlog
		Inherits BaseMessage
		Protected blogID As Integer = -1
		Protected parentID As Integer = -1
		' -1 means no parent. No parent means root blog entry
		Protected status As BlogStatus = BlogStatus.gbsInitial

		Public Enum BlogStatus
			gbsInitial = 0
			gbsApproved = 1
		End Enum

		Public Sub New(ByVal dr As SqlDataReader)
			Init(dr)
		End Sub

		Public Sub New(ByVal parentID As Integer, ByVal fromUID As Integer, ByVal subject As String, ByVal body As String)
			Me.parentID = parentID
			Me.senderUID = fromUID
			Me.subject = subject
			Me.body = body
		End Sub

		Public Sub New(ByVal fromUID As Integer, ByVal subject As String, ByVal body As String)
			Me.senderUID = fromUID
			Me.subject = subject
			Me.body = body
		End Sub

		Public Overloads Overrides WriteOnly Property Subject() As String
			Set
				subject = value
			End Set
		End Property

		Public Overloads Overrides WriteOnly Property Body() As String
			Set
				body = value
			End Set
		End Property

		Public Overloads Overrides ReadOnly Property ID() As Integer
			Get
				Return blogID
			End Get
		End Property

		Public ReadOnly Property ParentBlogID() As Integer
			Get
				Return parentID
			End Get
		End Property

		Public Property Status() As BlogStatus
			Get
				Return status
			End Get
			Set
				status = value
			End Set
		End Property

		Public Sub Approve()
			status = BlogStatus.gbsApproved
		End Sub

		Public ReadOnly Property IsRoot() As Boolean
			Get
				Return parentID < 0
			End Get
		End Property

		'
		' Private and protected methods
		'

		Protected MustOverride Sub Init(ByVal dr As SqlDataReader)
	End Class
End Namespace






